﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using NUnit.Framework;
using AL100.BankApplication.BLL;

namespace AL100.BankApplication.Tests
{
    [TestFixture]
    class Test_Commands
    {
        Bank _bank;

        [SetUp]
        public void SetUp()
        {
            _bank = Bank.Instance();
            
            _bank.Accounts.Clear();
        }



        [Test]
        public void Test_Command_Execution_Add()
        {
            AccountBase account =  _bank.CreateAccount("titi", "toto", 500);

            for (int i = 1; i < 6; i++)
            {
                account.Deposit(i);
            }

            bool condition1 = account.Balance == 515;

            // Annulation des opérations précédentes..
            foreach (var command in account.Commands.Values)
            {
                command.Unexecute();
            }

            bool condition2 = account.Balance == 0;

            Assert.IsTrue(condition1 && condition2);

        }

    }
}
